﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Kinect.Tests;

namespace TestAnalyzer
{
	/// <summary>
	/// Interaction logic for Results.xaml
	/// </summary>
	public partial class Results : Window
	{
        public Results()
        {
            this.InitializeComponent();

            // Insert code required on object creation below this point.
        }
        public Results(List<TestInfo> test)
        {
            this.InitializeComponent();

            treeViewItems.ItemsSource = test;
        }

        private void treeViewItems_SelectedItemChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs<object> e)
        {
            canvasClicks.Children.Clear();


            if (e.NewValue is TestInfo)
            {
                var test = e.NewValue as TestInfo;

                foreach (var item in test.Clicks)
                {
                    GetSpot(item);
                }
            }
        }

        private Ellipse GetSpot(ClickInfo info)
        {
            var elli = new Ellipse();

            elli.Width = 6;
            elli.Height = 6;

            canvasClicks.Children.Add(elli);

            Canvas.SetLeft(elli, info.X - 3);
            Canvas.SetTop(elli, info.Y - 3);

            if (info.RightButton)
            {
                elli.Fill = new SolidColorBrush(Color.FromRgb(0, 255, 0));
            }
            else
            {
                elli.Fill = new SolidColorBrush(Color.FromRgb(255, 0, 0));
            }

            return elli;
        }
	}
}